
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.lobster.inputs &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.lobster.inputs</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.lobster.inputs</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Module for reading Lobster output files. For more information</span>
<span class="sd">on LOBSTER see www.cohp.de.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">itertools</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">OrderedDict</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">List</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">spglib</span>
<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>
<span class="kn">from</span> <span class="nn">monty.serialization</span> <span class="kn">import</span> <span class="n">loadfn</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.inputs</span> <span class="kn">import</span> <span class="n">Incar</span><span class="p">,</span> <span class="n">Kpoints</span><span class="p">,</span> <span class="n">Potcar</span>
<span class="kn">from</span> <span class="nn">pymatgen.symmetry.bandstructure</span> <span class="kn">import</span> <span class="n">HighSymmKpath</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Janine George, Marco Esters&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2017, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.2&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Janine George, Marco Esters &quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;janine.george@uclouvain.be, esters@uoregon.edu&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Dec 13, 2017&quot;</span>

<span class="n">MODULE_DIR</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">))</span>


<div class="viewcode-block" id="Lobsterin"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin">[docs]</a><span class="k">class</span> <span class="nc">Lobsterin</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This class can handle and generate lobsterin files</span>
<span class="sd">    Furthermore, it can also modify INCAR files for lobster, generate KPOINT files for fatband calculations in Lobster,</span>
<span class="sd">    and generate the standard primitive cells in a POSCAR file that are needed for the fatband calculations.</span>
<span class="sd">    There are also several standard lobsterin files that can be easily generated.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># all keywords known to this class so far</span>
    <span class="c1"># reminder: lobster is not case sensitive</span>
    <span class="n">AVAILABLEKEYWORDS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;COHPstartEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;COHPendEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;basisSet&#39;</span><span class="p">,</span> <span class="s1">&#39;cohpGenerator&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;gaussianSmearingWidth&#39;</span><span class="p">,</span> <span class="s1">&#39;saveProjectionToFile&#39;</span><span class="p">,</span> <span class="s1">&#39;basisfunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;skipdos&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;skipcohp&#39;</span><span class="p">,</span> <span class="s1">&#39;skipcoop&#39;</span><span class="p">,</span> <span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">,</span> <span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;userecommendedbasisfunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;loadProjectionFromFile&#39;</span><span class="p">,</span> <span class="s1">&#39;forceEnergyRange&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;DensityOfEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;BWDF&#39;</span><span class="p">,</span> <span class="s1">&#39;BWDFCOHP&#39;</span><span class="p">,</span> <span class="s1">&#39;skipProjection&#39;</span><span class="p">,</span> <span class="s1">&#39;createFatband&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;writeBasisFunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;writeMatricesToFile&#39;</span><span class="p">,</span> <span class="s1">&#39;realspaceHamiltonian&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;realspaceOverlap&#39;</span><span class="p">,</span> <span class="s1">&#39;printPAWRealSpaceWavefunction&#39;</span><span class="p">,</span> <span class="s1">&#39;printLCAORealSpaceWavefunction&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;noFFTforVisualization&#39;</span><span class="p">,</span> <span class="s1">&#39;RMSp&#39;</span><span class="p">,</span> <span class="s1">&#39;onlyReadVasprun.xml&#39;</span><span class="p">,</span> <span class="s1">&#39;noMemoryMappedFiles&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;skipPAWOrthonormalityTest&#39;</span><span class="p">,</span> <span class="s1">&#39;doNotIgnoreExcessiveBands&#39;</span><span class="p">,</span> <span class="s1">&#39;doNotUseAbsoluteSpilling&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;skipReOrthonormalization&#39;</span><span class="p">,</span> <span class="s1">&#39;forceV1HMatrix&#39;</span><span class="p">,</span> <span class="s1">&#39;useOriginalTetrahedronMethod&#39;</span><span class="p">,</span>
                         <span class="s1">&#39;useDecimalPlaces&#39;</span><span class="p">,</span> <span class="s1">&#39;kSpaceCOHP&#39;</span><span class="p">]</span>

    <span class="c1"># keyword + one float can be used in file</span>
    <span class="n">FLOATKEYWORDS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;COHPstartEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;COHPendEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;gaussianSmearingWidth&#39;</span><span class="p">,</span> <span class="s1">&#39;useDecimalPlaces&#39;</span><span class="p">,</span> <span class="s1">&#39;COHPSteps&#39;</span><span class="p">]</span>
    <span class="c1"># one of these keywords +endstring can be used in file</span>
    <span class="n">STRINGKEYWORDS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;basisSet&#39;</span><span class="p">,</span> <span class="s1">&#39;cohpGenerator&#39;</span><span class="p">,</span> <span class="s1">&#39;realspaceHamiltonian&#39;</span><span class="p">,</span> <span class="s1">&#39;realspaceOverlap&#39;</span><span class="p">,</span>
                      <span class="s1">&#39;printPAWRealSpaceWavefunction&#39;</span><span class="p">,</span> <span class="s1">&#39;printLCAORealSpaceWavefunction&#39;</span><span class="p">,</span> <span class="s1">&#39;kSpaceCOHP&#39;</span><span class="p">]</span>
    <span class="c1"># the keyword alone will turn on or off a function</span>
    <span class="n">BOOLEANKEYWORDS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;saveProjectionToFile&#39;</span><span class="p">,</span> <span class="s1">&#39;skipdos&#39;</span><span class="p">,</span> <span class="s1">&#39;skipcohp&#39;</span><span class="p">,</span> <span class="s1">&#39;skipcoop&#39;</span><span class="p">,</span> <span class="s1">&#39;loadProjectionFromFile&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;forceEnergyRange&#39;</span><span class="p">,</span> <span class="s1">&#39;DensityOfEnergy&#39;</span><span class="p">,</span> <span class="s1">&#39;BWDF&#39;</span><span class="p">,</span> <span class="s1">&#39;BWDFCOHP&#39;</span><span class="p">,</span> <span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">,</span> <span class="s1">&#39;userecommendedbasisfunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;skipProjection&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;writeBasisFunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;writeMatricesToFile&#39;</span><span class="p">,</span> <span class="s1">&#39;noFFTforVisualization&#39;</span><span class="p">,</span> <span class="s1">&#39;RMSp&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;onlyReadVasprun.xml&#39;</span><span class="p">,</span> <span class="s1">&#39;noMemoryMappedFiles&#39;</span><span class="p">,</span> <span class="s1">&#39;skipPAWOrthonormalityTest&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;doNotIgnoreExcessiveBands&#39;</span><span class="p">,</span> <span class="s1">&#39;doNotUseAbsoluteSpilling&#39;</span><span class="p">,</span> <span class="s1">&#39;skipReOrthonormalization&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;forceV1HMatrix&#39;</span><span class="p">,</span> <span class="s1">&#39;useOriginalTetrahedronMethod&#39;</span><span class="p">,</span> <span class="s1">&#39;forceEnergyRange&#39;</span><span class="p">,</span> <span class="s1">&#39;bandwiseSpilling&#39;</span><span class="p">,</span>
                       <span class="s1">&#39;kpointwiseSpilling&#39;</span><span class="p">]</span>
    <span class="c1"># several of these keywords + ending can be used in a lobsterin file:</span>
    <span class="n">LISTKEYWORDS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;basisfunctions&#39;</span><span class="p">,</span> <span class="s1">&#39;cohpbetween&#39;</span><span class="p">,</span> <span class="s1">&#39;createFatband&#39;</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">settingsdict</span><span class="p">:</span> <span class="nb">dict</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            settingsdict: dict to initialize Lobsterin</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
        <span class="c1"># check for duplicates</span>
        <span class="n">listkey</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">settingsdict</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">listkey</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">listkey</span><span class="p">))):</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;There are duplicates for the keywords! The program will stop here.&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">settingsdict</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">val</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Add parameter-val pair to Lobsterin.  Warns if parameter is not in list of</span>
<span class="sd">        valid lobsterintags. Also cleans the parameter and val by stripping</span>
<span class="sd">        leading and trailing white spaces. Similar to INCAR class.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># due to the missing case sensitivity of lobster, the following code is neccessary</span>
        <span class="n">found</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">key_here</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key_here</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                <span class="n">new_key</span> <span class="o">=</span> <span class="n">key_here</span>
                <span class="n">found</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">found</span><span class="p">:</span>
            <span class="n">new_key</span> <span class="o">=</span> <span class="n">key</span>
        <span class="k">if</span> <span class="n">new_key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">AVAILABLEKEYWORDS</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Key is currently not available&quot;</span><span class="p">))</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__setitem__</span><span class="p">(</span><span class="n">new_key</span><span class="p">,</span> <span class="n">val</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">val</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        implements getitem from dict to avoid problems with cases</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">found</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">key_here</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key_here</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                <span class="n">new_key</span> <span class="o">=</span> <span class="n">key_here</span>
                <span class="n">found</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">found</span><span class="p">:</span>
            <span class="n">new_key</span> <span class="o">=</span> <span class="n">item</span>

        <span class="n">val</span> <span class="o">=</span> <span class="nb">dict</span><span class="o">.</span><span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">new_key</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">val</span>

<div class="viewcode-block" id="Lobsterin.diff"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.diff">[docs]</a>    <span class="k">def</span> <span class="nf">diff</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Diff function for lobsterin. Compares two lobsterin and indicates which parameters are the same.</span>
<span class="sd">        Similar to the diff in INCAR.</span>
<span class="sd">        Args:</span>
<span class="sd">            other (Lobsterin): Lobsterin object to compare to</span>
<span class="sd">        Returns:</span>
<span class="sd">            dict with differences and similarities</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">similar_param</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">different_param</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">key_list_others</span> <span class="o">=</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">other</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>

        <span class="k">for</span> <span class="n">k1</span><span class="p">,</span> <span class="n">v1</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">k1lower</span> <span class="o">=</span> <span class="n">k1</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">k1lower</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">key_list_others</span><span class="p">:</span>
                <span class="n">different_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;lobsterin1&quot;</span><span class="p">:</span> <span class="n">v1</span><span class="p">,</span> <span class="s2">&quot;lobsterin2&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">}</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">key_here</span> <span class="ow">in</span> <span class="n">other</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">k1</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key_here</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                        <span class="n">new_key</span> <span class="o">=</span> <span class="n">key_here</span>

                <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                    <span class="k">if</span> <span class="n">v1</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>

                        <span class="n">different_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;lobsterin1&quot;</span><span class="p">:</span> <span class="n">v1</span><span class="p">,</span> <span class="s2">&quot;lobsterin2&quot;</span><span class="p">:</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]}</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">similar_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="n">v1</span>
                <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                    <span class="n">new_set1</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="n">element</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">v1</span><span class="p">])</span>
                    <span class="n">new_set2</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="n">element</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]])</span>
                    <span class="k">if</span> <span class="n">new_set1</span> <span class="o">!=</span> <span class="n">new_set2</span><span class="p">:</span>
                        <span class="n">different_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;lobsterin1&quot;</span><span class="p">:</span> <span class="n">v1</span><span class="p">,</span> <span class="s2">&quot;lobsterin2&quot;</span><span class="p">:</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]}</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">v1</span> <span class="o">!=</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]:</span>
                        <span class="n">different_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;lobsterin1&quot;</span><span class="p">:</span> <span class="n">v1</span><span class="p">,</span> <span class="s2">&quot;lobsterin2&quot;</span><span class="p">:</span> <span class="n">other</span><span class="p">[</span><span class="n">new_key</span><span class="p">]}</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">similar_param</span><span class="p">[</span><span class="n">k1</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="n">v1</span>

        <span class="k">for</span> <span class="n">k2</span><span class="p">,</span> <span class="n">v2</span> <span class="ow">in</span> <span class="n">other</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">k2</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">similar_param</span> <span class="ow">and</span> <span class="n">k2</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">different_param</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">key_here</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">k2</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key_here</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                        <span class="n">new_key</span> <span class="o">=</span> <span class="n">key_here</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">new_key</span> <span class="o">=</span> <span class="n">k2</span>
                <span class="k">if</span> <span class="n">new_key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
                    <span class="n">different_param</span><span class="p">[</span><span class="n">k2</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;lobsterin1&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;lobsterin2&quot;</span><span class="p">:</span> <span class="n">v2</span><span class="p">}</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;Same&quot;</span><span class="p">:</span> <span class="n">similar_param</span><span class="p">,</span> <span class="s2">&quot;Different&quot;</span><span class="p">:</span> <span class="n">different_param</span><span class="p">}</span></div>

    <span class="k">def</span> <span class="nf">_get_nbands</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">:</span> <span class="n">Structure</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        get number of nbands</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;basisfunctions&quot;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;No basis functions are provided. The program cannot calculate nbands.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">basis_functions</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[str]</span>
            <span class="k">for</span> <span class="n">string_basis</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">[</span><span class="s2">&quot;basisfunctions&quot;</span><span class="p">]:</span>
                <span class="c1"># string_basis.lstrip()</span>
                <span class="n">string_basis_raw</span> <span class="o">=</span> <span class="n">string_basis</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)</span>
                <span class="k">while</span> <span class="s2">&quot;&quot;</span> <span class="ow">in</span> <span class="n">string_basis_raw</span><span class="p">:</span>
                    <span class="n">string_basis_raw</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">element_composition</span><span class="p">[</span><span class="n">string_basis_raw</span><span class="p">[</span><span class="mi">0</span><span class="p">]])):</span>
                    <span class="n">basis_functions</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">string_basis_raw</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>

        <span class="n">no_basis_functions</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">basis</span> <span class="ow">in</span> <span class="n">basis_functions</span><span class="p">:</span>
            <span class="k">if</span> <span class="s2">&quot;s&quot;</span> <span class="ow">in</span> <span class="n">basis</span><span class="p">:</span>
                <span class="n">no_basis_functions</span> <span class="o">=</span> <span class="n">no_basis_functions</span> <span class="o">+</span> <span class="mi">1</span>
            <span class="k">elif</span> <span class="s2">&quot;p&quot;</span> <span class="ow">in</span> <span class="n">basis</span><span class="p">:</span>
                <span class="n">no_basis_functions</span> <span class="o">=</span> <span class="n">no_basis_functions</span> <span class="o">+</span> <span class="mi">3</span>
            <span class="k">elif</span> <span class="s2">&quot;d&quot;</span> <span class="ow">in</span> <span class="n">basis</span><span class="p">:</span>
                <span class="n">no_basis_functions</span> <span class="o">=</span> <span class="n">no_basis_functions</span> <span class="o">+</span> <span class="mi">5</span>
            <span class="k">elif</span> <span class="s2">&quot;f&quot;</span> <span class="ow">in</span> <span class="n">basis</span><span class="p">:</span>
                <span class="n">no_basis_functions</span> <span class="o">=</span> <span class="n">no_basis_functions</span> <span class="o">+</span> <span class="mi">7</span>

        <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">no_basis_functions</span><span class="p">)</span>

<div class="viewcode-block" id="Lobsterin.write_lobsterin"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.write_lobsterin">[docs]</a>    <span class="k">def</span> <span class="nf">write_lobsterin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s2">&quot;lobsterin&quot;</span><span class="p">,</span> <span class="n">overwritedict</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        writes a lobsterin file</span>
<span class="sd">        Args:</span>
<span class="sd">            path (str): filename of the lobsterin file that will be written</span>
<span class="sd">            overwritedict (dict): dict that can be used to overwrite lobsterin, e.g. {&quot;skipdos&quot;: True}</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># will overwrite previous entries</span>
        <span class="c1"># has to search first if entry is already in Lobsterindict (due to case insensitivity)</span>
        <span class="k">if</span> <span class="n">overwritedict</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">overwritedict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">found</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">for</span> <span class="n">key2</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key2</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">[</span><span class="n">key2</span><span class="p">]</span> <span class="o">=</span> <span class="n">entry</span>
                        <span class="n">found</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">found</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">entry</span>

        <span class="n">filename</span> <span class="o">=</span> <span class="n">path</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">AVAILABLEKEYWORDS</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">()]:</span>
                    <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">FLOATKEYWORDS</span><span class="p">]:</span>
                        <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">BOOLEANKEYWORDS</span><span class="p">]:</span>
                        <span class="c1"># checks if entry is True or False</span>
                        <span class="k">for</span> <span class="n">key_here</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                            <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="n">key_here</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                                <span class="n">new_key</span> <span class="o">=</span> <span class="n">key_here</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">new_key</span><span class="p">):</span>
                            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">STRINGKEYWORDS</span><span class="p">]:</span>
                        <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">))</span>
                    <span class="k">elif</span> <span class="n">key</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="n">element</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">LISTKEYWORDS</span><span class="p">]:</span>
                        <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">):</span>
                            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lobsterin.as_dict"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: MSONable dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@module&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@class&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="Lobsterin.from_dict"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param d: Dict representation</span>
<span class="sd">        :return: Lobsterin</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Lobsterin</span><span class="p">({</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">d</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;@module&quot;</span><span class="p">,</span>
                                                                  <span class="s2">&quot;@class&quot;</span><span class="p">]})</span></div>

<div class="viewcode-block" id="Lobsterin.write_INCAR"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.write_INCAR">[docs]</a>    <span class="k">def</span> <span class="nf">write_INCAR</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">incar_input</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;INCAR&quot;</span><span class="p">,</span> <span class="n">incar_output</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;INCAR.lobster&quot;</span><span class="p">,</span> <span class="n">poscar_input</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span>
                    <span class="n">isym</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
                    <span class="n">further_settings</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Will only make the run static, insert nbands, make ISYM=-1, set LWAVE=True and write a new INCAR.</span>
<span class="sd">        You have to check for the rest.</span>
<span class="sd">        Args:</span>
<span class="sd">            incar_input (str): path to input INCAR</span>
<span class="sd">            incar_output (str): path to output INCAR</span>
<span class="sd">            poscar_input (str): path to input POSCAR</span>
<span class="sd">            isym (int): isym equal to -1 or 0 are possible. Current Lobster version only allow -1.</span>
<span class="sd">            further_settings (dict): A dict can be used to include further settings, e.g. {&quot;ISMEAR&quot;:-5}</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># reads old incar from file, this one will be modified</span>
        <span class="n">incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">incar_input</span><span class="p">)</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;Please check your incar_input before using it. This method only changes three settings!&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">isym</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISYM&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="k">elif</span> <span class="n">isym</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISYM&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;isym has to be -1 or 0.&quot;</span><span class="p">)</span>
        <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NSW&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LWAVE&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="c1"># get nbands from _get_nbands (use basis set that is inserted)</span>
        <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;NBANDS&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_nbands</span><span class="p">(</span><span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">poscar_input</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">further_settings</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">further_settings</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">incar</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">further_settings</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
        <span class="c1"># print it to file</span>
        <span class="n">incar</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="n">incar_output</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lobsterin.get_basis"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.get_basis">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_basis</span><span class="p">(</span><span class="n">structure</span><span class="p">:</span> <span class="n">Structure</span><span class="p">,</span> <span class="n">potcar_symbols</span><span class="p">:</span> <span class="nb">list</span><span class="p">,</span>
                  <span class="n">address_basis_file</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">MODULE_DIR</span><span class="p">,</span> <span class="s2">&quot;lobster_basis/BASIS_PBE_54_standard.yaml&quot;</span><span class="p">)):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will get the basis from given potcar_symbols (e.g., [&quot;Fe_pv&quot;,&quot;Si&quot;]</span>
<span class="sd">        #include this in lobsterin class</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Structure object</span>
<span class="sd">            potcar_symbols: list of potcar symbols</span>
<span class="sd">        Returns:</span>
<span class="sd">            returns basis</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">Potcar_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">potcar_symbols</span><span class="p">]</span>

        <span class="n">AtomTypes_Potcar</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">Potcar_names</span><span class="p">]</span>

        <span class="n">AtomTypes</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">symbol_set</span>

        <span class="k">if</span> <span class="nb">set</span><span class="p">(</span><span class="n">AtomTypes</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">set</span><span class="p">(</span><span class="n">AtomTypes_Potcar</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;Your POSCAR does not correspond to your POTCAR!&quot;</span><span class="p">)</span>
        <span class="n">BASIS</span> <span class="o">=</span> <span class="n">loadfn</span><span class="p">(</span><span class="n">address_basis_file</span><span class="p">)[</span><span class="s1">&#39;BASIS&#39;</span><span class="p">]</span>

        <span class="n">basis_functions</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_forin</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">itype</span><span class="p">,</span> <span class="nb">type</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">Potcar_names</span><span class="p">):</span>
            <span class="k">if</span> <span class="nb">type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">BASIS</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You have to provide the basis for&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span>
                    <span class="nb">type</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;manually. We don&#39;t have any information on this POTCAR.&quot;</span><span class="p">)</span>
            <span class="n">basis_functions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">BASIS</span><span class="p">[</span><span class="nb">type</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
            <span class="n">tojoin</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">AtomTypes_Potcar</span><span class="p">[</span><span class="n">itype</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span>
            <span class="n">tojoin2</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">BASIS</span><span class="p">[</span><span class="nb">type</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
            <span class="n">list_forin</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tojoin</span> <span class="o">+</span> <span class="n">tojoin2</span><span class="p">))</span>
        <span class="k">return</span> <span class="n">list_forin</span></div>

<div class="viewcode-block" id="Lobsterin.get_all_possible_basis_functions"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.get_all_possible_basis_functions">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_all_possible_basis_functions</span><span class="p">(</span><span class="n">structure</span><span class="p">:</span> <span class="n">Structure</span><span class="p">,</span>
                                         <span class="n">potcar_symbols</span><span class="p">:</span> <span class="nb">list</span><span class="p">,</span>
                                         <span class="n">address_basis_file_min</span><span class="p">:</span>
                                         <span class="nb">str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">MODULE_DIR</span><span class="p">,</span>
                                                            <span class="s2">&quot;lobster_basis/BASIS_PBE_54_min.yaml&quot;</span><span class="p">),</span>
                                         <span class="n">address_basis_file_max</span><span class="p">:</span>
                                         <span class="nb">str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">MODULE_DIR</span><span class="p">,</span>
                                                            <span class="s2">&quot;lobster_basis/BASIS_PBE_54_max.yaml&quot;</span><span class="p">)):</span>

        <span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            structure: Structure object</span>
<span class="sd">            potcar_symbols: list of the potcar symbols</span>
<span class="sd">            address_basis_file_min: path to file with the minium required basis by the POTCAR</span>
<span class="sd">            address_basis_file_max: path to file with the largest possible basis of the POTCAR</span>

<span class="sd">        Returns: List of dictionaries that can be used to create new Lobsterin objects in </span>
<span class="sd">        standard_calculations_from_vasp_files as dict_for_basis</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">max_basis</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">get_basis</span><span class="p">(</span><span class="n">structure</span><span class="o">=</span><span class="n">structure</span><span class="p">,</span> <span class="n">potcar_symbols</span><span class="o">=</span><span class="n">potcar_symbols</span><span class="p">,</span>
                                        <span class="n">address_basis_file</span><span class="o">=</span><span class="n">address_basis_file_max</span><span class="p">)</span>
        <span class="n">min_basis</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">get_basis</span><span class="p">(</span><span class="n">structure</span><span class="o">=</span><span class="n">structure</span><span class="p">,</span> <span class="n">potcar_symbols</span><span class="o">=</span><span class="n">potcar_symbols</span><span class="p">,</span>
                                        <span class="n">address_basis_file</span><span class="o">=</span><span class="n">address_basis_file_min</span><span class="p">)</span>
        <span class="n">all_basis</span> <span class="o">=</span> <span class="n">get_all_possible_basis_combinations</span><span class="p">(</span><span class="n">min_basis</span><span class="o">=</span><span class="n">min_basis</span><span class="p">,</span> <span class="n">max_basis</span><span class="o">=</span><span class="n">max_basis</span><span class="p">)</span>
        <span class="n">list_basis_dict</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">ibasis</span><span class="p">,</span> <span class="n">basis</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">all_basis</span><span class="p">):</span>
            <span class="n">basis_dict</span> <span class="o">=</span> <span class="p">{}</span>

            <span class="k">for</span> <span class="n">iel</span><span class="p">,</span> <span class="n">elba</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">basis</span><span class="p">):</span>
                <span class="n">basplit</span> <span class="o">=</span> <span class="n">elba</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="n">basis_dict</span><span class="p">[</span><span class="n">basplit</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">basplit</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
            <span class="n">list_basis_dict</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">basis_dict</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">list_basis_dict</span></div>

<div class="viewcode-block" id="Lobsterin.write_POSCAR_with_standard_primitive"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.write_POSCAR_with_standard_primitive">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">write_POSCAR_with_standard_primitive</span><span class="p">(</span><span class="n">POSCAR_input</span><span class="o">=</span><span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="n">POSCAR_output</span><span class="o">=</span><span class="s2">&quot;POSCAR.lobster&quot;</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="mf">0.01</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        writes a POSCAR with the standard primitive cell. This is needed to arrive at the correct kpath</span>
<span class="sd">        Args:</span>
<span class="sd">            POSCAR_input (str): filename of input POSCAR</span>
<span class="sd">            POSCAR_output (str): filename of output POSCAR</span>
<span class="sd">            symprec (float): precision to find symmetry</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">POSCAR_input</span><span class="p">)</span>
        <span class="n">kpath</span> <span class="o">=</span> <span class="n">HighSymmKpath</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="n">symprec</span><span class="p">)</span>
        <span class="n">new_structure</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">prim</span>
        <span class="n">new_structure</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">fmt</span><span class="o">=</span><span class="s1">&#39;POSCAR&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="n">POSCAR_output</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lobsterin.write_KPOINTS"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.write_KPOINTS">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">write_KPOINTS</span><span class="p">(</span><span class="n">POSCAR_input</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="n">KPOINTS_output</span><span class="o">=</span><span class="s2">&quot;KPOINTS.lobster&quot;</span><span class="p">,</span> <span class="n">reciprocal_density</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span>
                      <span class="n">isym</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">from_grid</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">input_grid</span><span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="n">line_mode</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
                      <span class="n">kpoints_line_density</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">20</span><span class="p">,</span> <span class="n">symprec</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        writes a KPOINT file for lobster (only ISYM=-1 and ISYM=0 are possible), grids are gamma centered</span>
<span class="sd">        Args:</span>
<span class="sd">            POSCAR_input (str): path to POSCAR</span>
<span class="sd">            KPOINTS_output (str): path to output KPOINTS</span>
<span class="sd">            reciprocal_density (int): Grid density</span>
<span class="sd">            isym (int): either -1 or 0. Current Lobster versions only allow -1.</span>
<span class="sd">            from_grid (bool): If True KPOINTS will be generated with the help of a grid given in input_grid. Otherwise,</span>
<span class="sd">                they will be generated from the reciprocal_density</span>
<span class="sd">            input_grid (list): grid to generate the KPOINTS file</span>
<span class="sd">            line_mode (bool): If True, band structure will be generated</span>
<span class="sd">            kpoints_line_density (int): density of the lines in the band structure</span>
<span class="sd">            symprec (float): precision to determine symmetry</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">POSCAR_input</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">from_grid</span><span class="p">:</span>
            <span class="n">kpointgrid</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">automatic_density_by_vol</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">reciprocal_density</span><span class="p">)</span><span class="o">.</span><span class="n">kpts</span>
            <span class="n">mesh</span> <span class="o">=</span> <span class="n">kpointgrid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">mesh</span> <span class="o">=</span> <span class="n">input_grid</span>

        <span class="c1"># The following code is taken from: SpacegroupAnalyzer</span>
        <span class="c1"># we need to switch off symmetry here</span>
        <span class="n">latt</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">matrix</span>
        <span class="n">positions</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">frac_coords</span>
        <span class="n">unique_species</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[Any]</span>
        <span class="n">zs</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">magmoms</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">for</span> <span class="n">species</span><span class="p">,</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span>
                                            <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">s</span><span class="p">:</span> <span class="n">s</span><span class="o">.</span><span class="n">species</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">species</span> <span class="ow">in</span> <span class="n">unique_species</span><span class="p">:</span>
                <span class="n">ind</span> <span class="o">=</span> <span class="n">unique_species</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">species</span><span class="p">)</span>
                <span class="n">zs</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="n">ind</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">g</span><span class="p">)))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">unique_species</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">species</span><span class="p">)</span>
                <span class="n">zs</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">unique_species</span><span class="p">)]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">g</span><span class="p">)))</span>

        <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="s1">&#39;magmom&#39;</span><span class="p">):</span>
                <span class="n">magmoms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">magmom</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">site</span><span class="o">.</span><span class="n">is_ordered</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="p">,</span> <span class="s1">&#39;spin&#39;</span><span class="p">):</span>
                <span class="n">magmoms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">spin</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">magmoms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

        <span class="c1"># For now, we are setting magmom to zero. (Taken from INCAR class)</span>
        <span class="n">cell</span> <span class="o">=</span> <span class="n">latt</span><span class="p">,</span> <span class="n">positions</span><span class="p">,</span> <span class="n">zs</span><span class="p">,</span> <span class="n">magmoms</span>
        <span class="c1"># TODO: what about this shift?</span>
        <span class="n">mapping</span><span class="p">,</span> <span class="n">grid</span> <span class="o">=</span> <span class="n">spglib</span><span class="o">.</span><span class="n">get_ir_reciprocal_mesh</span><span class="p">(</span><span class="n">mesh</span><span class="p">,</span> <span class="n">cell</span><span class="p">,</span> <span class="n">is_shift</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>

        <span class="c1"># exit()</span>
        <span class="c1"># get the kpoints for the grid</span>
        <span class="k">if</span> <span class="n">isym</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
            <span class="n">kpts</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">weights</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">all_labels</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">gp</span> <span class="ow">in</span> <span class="n">grid</span><span class="p">:</span>
                <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">gp</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span> <span class="o">/</span> <span class="n">mesh</span><span class="p">)</span>
                <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
                <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">isym</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="c1"># time reversal symmetry: k and -k are equivalent</span>
            <span class="n">kpts</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">weights</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">all_labels</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">newlist</span> <span class="o">=</span> <span class="p">[</span><span class="nb">list</span><span class="p">(</span><span class="n">gp</span><span class="p">)</span> <span class="k">for</span> <span class="n">gp</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">grid</span><span class="p">)]</span>
            <span class="n">mapping</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">gp</span> <span class="ow">in</span> <span class="n">newlist</span><span class="p">:</span>
                <span class="n">minusgp</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">gp</span><span class="p">]</span>
                <span class="k">if</span> <span class="n">minusgp</span> <span class="ow">in</span> <span class="n">newlist</span> <span class="ow">and</span> <span class="n">minusgp</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]]:</span>
                    <span class="n">mapping</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">newlist</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">minusgp</span><span class="p">))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">mapping</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">newlist</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">gp</span><span class="p">))</span>

            <span class="k">for</span> <span class="n">igp</span><span class="p">,</span> <span class="n">gp</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">newlist</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">mapping</span><span class="p">[</span><span class="n">igp</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">igp</span><span class="p">:</span>
                    <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">gp</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span> <span class="o">/</span> <span class="n">mesh</span><span class="p">)</span>
                    <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
                    <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">mapping</span><span class="p">[</span><span class="n">igp</span><span class="p">]</span> <span class="o">==</span> <span class="n">igp</span><span class="p">:</span>
                    <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">gp</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span> <span class="o">/</span> <span class="n">mesh</span><span class="p">)</span>
                    <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
                    <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Only isym=-1 and isym=0 are allowed.&quot;</span><span class="p">)</span>
        <span class="c1"># line mode</span>
        <span class="k">if</span> <span class="n">line_mode</span><span class="p">:</span>
            <span class="n">kpath</span> <span class="o">=</span> <span class="n">HighSymmKpath</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="n">symprec</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">kpath</span><span class="o">.</span><span class="n">prim</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">matrix</span><span class="p">,</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">matrix</span><span class="p">):</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;You are not using the standard primitive cell. The k-path is not correct. Please generate a &quot;</span>
                    <span class="s2">&quot;standard primitive cell first.&quot;</span><span class="p">)</span>

            <span class="n">frac_k_points</span><span class="p">,</span> <span class="n">labels</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">get_kpoints</span><span class="p">(</span>
                <span class="n">line_density</span><span class="o">=</span><span class="n">kpoints_line_density</span><span class="p">,</span>
                <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">)):</span>
                <span class="n">kpts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frac_k_points</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
                <span class="n">weights</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
                <span class="n">all_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">labels</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">isym</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
            <span class="n">comment</span> <span class="o">=</span> <span class="p">(</span>
                <span class="s2">&quot;ISYM=-1, grid: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">line_mode</span> <span class="k">else</span> <span class="s2">&quot;ISYM=-1, grid: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; plus kpoint path&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">isym</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">comment</span> <span class="o">=</span> <span class="p">(</span>
                <span class="s2">&quot;ISYM=0, grid: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">line_mode</span> <span class="k">else</span> <span class="s2">&quot;ISYM=0, grid: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">mesh</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; plus kpoint path&quot;</span><span class="p">)</span>

        <span class="n">KpointObject</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="p">(</span><span class="n">comment</span><span class="o">=</span><span class="n">comment</span><span class="p">,</span>
                               <span class="n">style</span><span class="o">=</span><span class="n">Kpoints</span><span class="o">.</span><span class="n">supported_modes</span><span class="o">.</span><span class="n">Reciprocal</span><span class="p">,</span>
                               <span class="n">num_kpts</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">kpts</span><span class="p">),</span> <span class="n">kpts</span><span class="o">=</span><span class="n">kpts</span><span class="p">,</span> <span class="n">kpts_weights</span><span class="o">=</span><span class="n">weights</span><span class="p">,</span>
                               <span class="n">labels</span><span class="o">=</span><span class="n">all_labels</span><span class="p">)</span>

        <span class="n">KpointObject</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">KPOINTS_output</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lobsterin.from_file"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.from_file">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_file</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">lobsterin</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            lobsterin (str): path to lobsterin</span>

<span class="sd">        Returns:</span>
<span class="sd">            Lobsterin object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">lobsterin</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;lobsterin file contains no data.&quot;</span><span class="p">)</span>
        <span class="n">Lobsterindict</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># type: Dict</span>

        <span class="k">for</span> <span class="n">datum</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="c1"># will remove all commments to avoid complications</span>
            <span class="n">raw_datum</span> <span class="o">=</span> <span class="n">datum</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;!&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">raw_datum</span> <span class="o">=</span> <span class="n">raw_datum</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;//&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">raw_datum</span> <span class="o">=</span> <span class="n">raw_datum</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;#&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">raw_datum</span> <span class="o">=</span> <span class="n">raw_datum</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span>
            <span class="k">while</span> <span class="s2">&quot;&quot;</span> <span class="ow">in</span> <span class="n">raw_datum</span><span class="p">:</span>
                <span class="n">raw_datum</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="c1"># check which type of keyword this is, handle accordingly</span>
                <span class="k">if</span> <span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">datum2</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">datum2</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">LISTKEYWORDS</span><span class="p">]:</span>
                    <span class="k">if</span> <span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">datum2</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">datum2</span> <span class="ow">in</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">FLOATKEYWORDS</span><span class="p">]:</span>
                        <span class="k">if</span> <span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Lobsterindict</span><span class="p">:</span>
                            <span class="n">Lobsterindict</span><span class="p">[</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Same keyword &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot;twice!&quot;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Lobsterindict</span><span class="p">:</span>
                            <span class="n">Lobsterindict</span><span class="p">[</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Same keyword &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot;twice!&quot;</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Lobsterindict</span><span class="p">:</span>
                        <span class="n">Lobsterindict</span><span class="p">[</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">1</span><span class="p">:])]</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">Lobsterindict</span><span class="p">[</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_datum</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">Lobsterindict</span><span class="p">[</span><span class="n">raw_datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">Lobsterindict</span><span class="p">)</span></div>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_get_potcar_symbols</span><span class="p">(</span><span class="n">POTCAR_input</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will return the name of the species in the POTCAR</span>
<span class="sd">        Args:</span>
<span class="sd">         POTCAR_input(str): string to potcar file</span>
<span class="sd">        Returns:</span>
<span class="sd">            list of the names of the species in string format</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">potcar</span> <span class="o">=</span> <span class="n">Potcar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">POTCAR_input</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">pot</span> <span class="ow">in</span> <span class="n">potcar</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">pot</span><span class="o">.</span><span class="n">potential_type</span> <span class="o">!=</span> <span class="s2">&quot;PAW&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;Lobster only works with PAW! Use different POTCARs&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">potcar</span><span class="o">.</span><span class="n">functional</span> <span class="o">!=</span> <span class="s2">&quot;PBE&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;We only have BASIS options for PBE so far&quot;</span><span class="p">)</span>

        <span class="n">Potcar_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span><span class="p">[</span><span class="s2">&quot;symbol&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">potcar</span><span class="o">.</span><span class="n">spec</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">Potcar_names</span>

<div class="viewcode-block" id="Lobsterin.standard_calculations_from_vasp_files"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.Lobsterin.standard_calculations_from_vasp_files">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">standard_calculations_from_vasp_files</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">POSCAR_input</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="n">INCAR_input</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;INCAR&quot;</span><span class="p">,</span>
                                              <span class="n">POTCAR_input</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
                                              <span class="n">dict_for_basis</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
                                              <span class="n">option</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;standard&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will generate Lobsterin with standard settings</span>

<span class="sd">        Args:</span>
<span class="sd">            POSCAR_input(str): path to POSCAR</span>
<span class="sd">            INCAR_input(str): path to INCAR</span>
<span class="sd">            POTCAR_input (str): path to POTCAR</span>
<span class="sd">            dict_for_basis (dict): can be provided: it should look the following:</span>
<span class="sd">                dict_for_basis={&quot;Fe&quot;:&#39;3p 3d 4s 4f&#39;, &quot;C&quot;: &#39;2s 2p&#39;} and will overwrite all settings from POTCAR_input</span>

<span class="sd">            option (str): &#39;standard&#39; will start a normal lobster run where COHPs, COOPs, DOS, CHARGE etc. will be</span>
<span class="sd">                calculated</span>
<span class="sd">                &#39;standard_from_projection&#39; will start a normal lobster run from a projection</span>
<span class="sd">                &#39;standard_with_fatband&#39; will do a fatband calculation, run over all orbitals</span>
<span class="sd">                &#39;onlyprojection&#39; will only do a projection</span>
<span class="sd">                &#39;onlydos&#39; will only calculate a projected dos</span>
<span class="sd">                &#39;onlycohp&#39; will only calculate cohp</span>
<span class="sd">                &#39;onlycoop&#39; will only calculate coop</span>
<span class="sd">                &#39;onlycohpcoop&#39; will only calculate cohp and coop</span>

<span class="sd">        Returns:</span>
<span class="sd">            Lobsterin Object with standard settings</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
            <span class="s2">&quot;Always check and test the provided basis functions. The spilling of your Lobster calculation might help&quot;</span><span class="p">)</span>
        <span class="c1"># warn that fatband calc cannot be done with tetrahedron method at the moment</span>
        <span class="k">if</span> <span class="n">option</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;standard&#39;</span><span class="p">,</span> <span class="s1">&#39;standard_from_projection&#39;</span><span class="p">,</span> <span class="s1">&#39;standard_with_fatband&#39;</span><span class="p">,</span> <span class="s1">&#39;onlyprojection&#39;</span><span class="p">,</span> <span class="s1">&#39;onlydos&#39;</span><span class="p">,</span>
                          <span class="s1">&#39;onlycohp&#39;</span><span class="p">,</span> <span class="s1">&#39;onlycoop&#39;</span><span class="p">,</span> <span class="s1">&#39;onlycohpcoop&#39;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;The option is not valid!&quot;</span><span class="p">)</span>

        <span class="n">Lobsterindict</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># type: Dict[Any,Any]</span>
        <span class="c1"># this basis set covers most elements</span>
        <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;basisSet&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;pbeVaspFit2015&#39;</span>
        <span class="c1"># energies around e-fermi</span>
        <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;COHPstartEnergy&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mf">15.0</span>
        <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;COHPendEnergy&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">5.0</span>

        <span class="k">if</span> <span class="n">option</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;standard&#39;</span><span class="p">,</span> <span class="s1">&#39;onlycohp&#39;</span><span class="p">,</span> <span class="s1">&#39;onlycoop&#39;</span><span class="p">,</span> <span class="s1">&#39;onlycohpcoop&#39;</span><span class="p">,</span> <span class="s1">&#39;standard_with_fatband&#39;</span><span class="p">]:</span>
            <span class="c1"># every interaction with a distance of 6.0 is checked</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;cohpGenerator&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;from 0.1 to 6.0 orbitalwise&quot;</span>
            <span class="c1"># the projection is saved</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;saveProjectionToFile&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;standard_from_projection&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;cohpGenerator&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;from 0.1 to 6.0 orbitalwise&quot;</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;loadProjectionFromFile&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;onlycohp&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipdos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcoop&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;onlycoop&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipdos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcohp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;onlycohpcoop&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipdos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;onlydos&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcohp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcoop&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;onlyprojection&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipdos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcohp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipcoop&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipPopulationAnalysis&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;skipGrossPopulation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;saveProjectionToFile&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="n">incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">INCAR_input</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;gaussianSmearingWidth&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;SIGMA&quot;</span><span class="p">]</span>
        <span class="k">if</span> <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;ISMEAR&quot;</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">option</span> <span class="o">==</span> <span class="s2">&quot;standard_with_fatband&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;ISMEAR has to be 0 for a fatband calculation with Lobster&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">dict_for_basis</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># dict_for_basis={&quot;Fe&quot;:&#39;3p 3d 4s 4f&#39;, &quot;C&quot;: &#39;2s 2p&#39;}</span>
            <span class="c1"># will just insert this basis and not check with poscar</span>
            <span class="n">basis</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="n">value</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">dict_for_basis</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
        <span class="k">elif</span> <span class="n">POTCAR_input</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># get basis from POTCAR</span>
            <span class="n">potcar_names</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">_get_potcar_symbols</span><span class="p">(</span><span class="n">POTCAR_input</span><span class="o">=</span><span class="n">POTCAR_input</span><span class="p">)</span>

            <span class="n">basis</span> <span class="o">=</span> <span class="n">Lobsterin</span><span class="o">.</span><span class="n">get_basis</span><span class="p">(</span><span class="n">structure</span><span class="o">=</span><span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">POSCAR_input</span><span class="p">),</span>
                                        <span class="n">potcar_symbols</span><span class="o">=</span><span class="n">potcar_names</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;basis cannot be generated&quot;</span><span class="p">)</span>
        <span class="n">Lobsterindict</span><span class="p">[</span><span class="s2">&quot;basisfunctions&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">basis</span>
        <span class="k">if</span> <span class="n">option</span> <span class="o">==</span> <span class="s1">&#39;standard_with_fatband&#39;</span><span class="p">:</span>
            <span class="n">Lobsterindict</span><span class="p">[</span><span class="s1">&#39;createFatband&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">basis</span>

        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">Lobsterindict</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="get_all_possible_basis_combinations"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.inputs.html#pymatgen.io.lobster.inputs.get_all_possible_basis_combinations">[docs]</a><span class="k">def</span> <span class="nf">get_all_possible_basis_combinations</span><span class="p">(</span><span class="n">min_basis</span><span class="p">:</span> <span class="nb">list</span><span class="p">,</span> <span class="n">max_basis</span><span class="p">:</span> <span class="nb">list</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>

<span class="sd">    Args:</span>
<span class="sd">        min_basis: list of basis entries: e.g., [&#39;Si 3p 3s &#39;]</span>
<span class="sd">        max_basis: list of basis entries: e.g., [&#39;Si 3p 3s &#39;]</span>

<span class="sd">    Returns: all possible combinations of basis functions, e.g. [[&#39;Si 3p 3s&#39;]]</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">max_basis_lists</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">max_basis</span><span class="p">]</span>
    <span class="n">min_basis_lists</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">min_basis</span><span class="p">]</span>

    <span class="c1"># get all possible basis functions</span>
    <span class="n">basis_dict</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">({})</span>  <span class="c1"># type:  Dict[Any, Any]</span>
    <span class="k">for</span> <span class="n">iel</span><span class="p">,</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">max_basis_lists</span><span class="p">):</span>
        <span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;fixed&quot;</span><span class="p">:</span> <span class="p">[],</span> <span class="s2">&quot;variable&quot;</span><span class="p">:</span> <span class="p">[],</span> <span class="s2">&quot;combinations&quot;</span><span class="p">:</span> <span class="p">[]}</span>
        <span class="k">for</span> <span class="n">basis</span> <span class="ow">in</span> <span class="n">el</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
            <span class="k">if</span> <span class="n">basis</span> <span class="ow">in</span> <span class="n">min_basis_lists</span><span class="p">[</span><span class="n">iel</span><span class="p">]:</span>
                <span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s2">&quot;fixed&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">basis</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">basis</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">min_basis_lists</span><span class="p">[</span><span class="n">iel</span><span class="p">]:</span>
                <span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s2">&quot;variable&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">basis</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">L</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s1">&#39;variable&#39;</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">subset</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">combinations</span><span class="p">(</span><span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s1">&#39;variable&#39;</span><span class="p">],</span> <span class="n">L</span><span class="p">):</span>
                <span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s2">&quot;combinations&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">+</span> <span class="n">basis_dict</span><span class="p">[</span><span class="n">el</span><span class="p">[</span><span class="mi">0</span><span class="p">]][</span><span class="s1">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="n">subset</span><span class="p">)))</span>

    <span class="n">list_basis</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">el</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">basis_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
        <span class="n">list_basis</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;combinations&#39;</span><span class="p">])</span>

    <span class="c1"># get all combinations</span>
    <span class="n">start_basis</span> <span class="o">=</span> <span class="n">list_basis</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">list_basis</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">iel</span><span class="p">,</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">list_basis</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span> <span class="mi">1</span><span class="p">):</span>
            <span class="n">new_start_basis</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">ielbasis</span><span class="p">,</span> <span class="n">elbasis</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">start_basis</span><span class="p">):</span>

                <span class="k">for</span> <span class="n">ielbasis2</span><span class="p">,</span> <span class="n">elbasis2</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">list_basis</span><span class="p">[</span><span class="n">iel</span><span class="p">]):</span>
                    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">elbasis</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">list</span><span class="p">:</span>
                        <span class="n">new_start_basis</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">elbasis</span><span class="p">,</span> <span class="n">elbasis2</span><span class="p">])</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">new_start_basis</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">elbasis</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">+</span> <span class="p">[</span><span class="n">elbasis2</span><span class="p">])</span>
            <span class="n">start_basis</span> <span class="o">=</span> <span class="n">new_start_basis</span>
        <span class="k">return</span> <span class="n">start_basis</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">return</span> <span class="p">[[</span><span class="n">basis</span><span class="p">]</span> <span class="k">for</span> <span class="n">basis</span> <span class="ow">in</span> <span class="n">start_basis</span><span class="p">]</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.lobster.inputs</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>